﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

namespace PlusTween
{
    public class PlusTweenColor : PlusTweenBase
    {

        public Color from = Color.white;
        public Color to = Color.white;

        private MaskableGraphic maskableGraphic;

        public Color value
        {
            get {
                return maskableGraphic.color;
            }
            set
            {
                maskableGraphic.color = value;
            }
            
        }

        private void Start()
        {
            maskableGraphic = gameObject.GetComponent<MaskableGraphic>();
        }

        private void OnEnable()
        {
            if (isBronOrigin) { SetValueFrom(); }
        }
        public override void StartIn()
        {
            if (null != maskableGraphic) { maskableGraphic.color = from; maskableGraphic.DOColor(to, duration); }
        }

        public override void StartOut()
        {
            if (null != maskableGraphic) { maskableGraphic.color = to; maskableGraphic.DOColor(from, duration); }
        }

        public override void SetValueFrom() { value = from; }
        public override void SetValueTo() { value = to; }

    }
}